
import numpy as np

# 生成0到4长度为5的数组
def fun1():
    x = np.arange(5)
    print(x)

# 设置返回类型为float
def fun2():
    x = np.arange(5, dtype=float)
    print(x)

# 设置了起始值、终止值及步长
def fun3():
    x = np.arange(10, 20, 2)
    print(x)

# numpy.linspace 用于创建一个一维数组，数组是一个等差数列构成
def fun4():
    a = np.linspace(1, 10, 10)
    print(a)

# 设置元素全部是1的等差数列
def fun5():
    a = np.linspace(1, 1, 10)
    print(a)

# 将endpoint设为false，不包含终止值
def fun6():
    a = np.linspace(10, 20, 5, endpoint=False)
    print(a)

# 设置间距
def fun7():
    a = np.linspace(1, 10, 10, retstep=True)
    print(a)

    b = np.linspace(1, 10, 10).reshape([10, 1])
    print(b)

# numpy.logspace用于创建一个等比数列
def fun8():
    # 默认底数是10
    a = np.logspace(1, 2, num=10)
    print(a)

# 将对数的底数设置为2
def fun9():
    a = np.logspace(0, 9, 10, base=2)
    print(a)

if __name__ == '__main__':
    fun9()